<%@ page contentType="text/html;charset=utf-8" %>
<%
	request.setCharacterEncoding("utf-8");
	int money;
	if(request.getParameter("money") == null){ // CANCEL_URL
		if(request.getParameter("error") == null){
%>
<script type="text/javascript">
if(window.opener){
	window.close();
}
</script>
<%
		}else if(request.getParameter("error").equals("number")){
%>
<script type="text/javascript">
if(window.opener){
	window.opener.Message.show("msg-deposit-error", 400, "儲值金額輸入錯誤", "儲值金額必須介於 NTD 200 元至 50000 元之間", window.opener.Message.BUTTON_OK);
	window.close();
}
</script>
<%
		}else{
%>
<script type="text/javascript">
if(window.opener){
	window.opener.Message.show("msg-deposit-error", 400, "儲值金額輸入錯誤", "儲值金額請輸入阿拉伯數字", window.opener.Message.BUTTON_OK);
	window.close();
}
</script>
<%
		}
	}else{ // RETURN_URL
		if(request.getParameter("token") == null || request.getParameter("PayerID") == null){ // 必要的參數不存在，不處理
			return;
		}
		try{
			money = Integer.parseInt(request.getParameter("money"));
		}catch(NumberFormatException e){
			return;
		}
%>
<script type="text/javascript">
if(window.opener){
	window.opener.doPayment(<%= money %>, "<%= request.getParameter("token") %>", "<%= request.getParameter("PayerID") %>");
	window.close();
}
</script>
<%
	}
%>